﻿package mortal.game.view.copy.towerCopy
{
    import Message.Game.*;
    import Message.Public.*;
    import __AS3__.vec.*;
    import fl.data.*;
    import flash.utils.*;
    import mortal.component.gconst.*;
    import mortal.game.resource.tableConfig.*;

    public class TowerCache extends Object
    {
        public var isDropEnd:Boolean;
        public var dropItems:Array;
        private var _scanStatus:Dictionary;
        private var _rankList:Vector.<STowerPlayer>;
        private var _towerPassMsg:STowerCopy2PassMsg;
        private var _towerCopyInfo:STowerCopy2Info;
        private var _towerTopList:STowerTopListMsg;
        public var towerInfoDic:Dictionary;
        public static const LoginLevel:int = 30;

        public function TowerCache()
        {
            this.dropItems = [];
            this._scanStatus = new Dictionary();
            this.towerInfoDic = new Dictionary();
            var _loc_1:* = new STowerInfo();
            _loc_1.money = new Dictionary();
            var _loc_2:* = new STowerInfo();
            _loc_2.money = new Dictionary();
            var _loc_3:* = new STowerInfo();
            _loc_3.money = new Dictionary();
            this.towerInfoDic["131"] = _loc_1;
            this.towerInfoDic["132"] = _loc_2;
            this.towerInfoDic["133"] = _loc_3;
            return;
        }// end function

        public function get towerPassMsg() : STowerCopy2PassMsg
        {
            return this._towerPassMsg;
        }// end function

        public function getPlayerMaxPass(param1:int) : int
        {
            return this.towerInfoDic[param1.toString()].currentPassLevel;
        }// end function

        public function getHistoryMaxLv(param1:int) : int
        {
            return this.towerInfoDic[param1.toString()].maxPassLevel;
        }// end function

        public function setScanStatus(param1:int, param2:int) : void
        {
            this._scanStatus[param1.toString()] = param2;
            return;
        }// end function

        public function getScanStatus(param1:int) : int
        {
            return int(this._scanStatus[param1.toString()]);
        }// end function

        public function getTowerInfo(param1:int) : STowerInfo
        {
            return this.towerInfoDic[param1.toString()] as STowerInfo;
        }// end function

        public function set towerPassMsg(param1:STowerCopy2PassMsg) : void
        {
            this._towerPassMsg = param1;
            if (param1)
            {
                this.towerInfoDic[param1.copyCode.toString()].currentPassLevel = this._towerPassMsg.level;
            }
            return;
        }// end function

        public function get towerCopyInfo() : STowerCopy2Info
        {
            return this._towerCopyInfo;
        }// end function

        public function set towerCopyInfo(param1:STowerCopy2Info) : void
        {
            this._towerCopyInfo = param1;
            return;
        }// end function

        public function get towerTopList() : STowerTopListMsg
        {
            return this._towerTopList;
        }// end function

        public function set towerTopList(param1:STowerTopListMsg) : void
        {
            var _loc_2:STowerPlayer = null;
            this._towerTopList = param1;
            if (this._rankList)
            {
                this._rankList.length = 0;
            }
            else
            {
                this._rankList = new Vector.<STowerPlayer>;
            }
            for each (_loc_2 in param1.towerTopLists)
            {
                
                this._rankList.push(_loc_2);
            }
            return;
        }// end function

        public function get rankList() : Vector.<STowerPlayer>
        {
            return this._rankList;
        }// end function

        public function getCurrentLevel(param1:int) : int
        {
            return TowerCopyConfig.instance.getInfoByID(param1, (this.getPlayerMaxPass(param1) + 1)) ? ((this.getPlayerMaxPass(param1) + 1)) : (this.getPlayerMaxPass(param1));
        }// end function

        public function getCurrentPassRewards(param1:int) : Vector.<ItemData>
        {
            return TowerCopyConfig.instance.getPassRewardsByID(param1, this.getCurrentLevel(param1));
        }// end function

        public function getHasFinishAllPass(param1:int) : Boolean
        {
            if (this.towerCopyInfo && this.towerCopyInfo.result && GameConst.TConstTowerMaxLevel == this.getPlayerMaxPass(param1))
            {
                return true;
            }
            return false;
        }// end function

        public function getCurrentPassRewardsDataProvider(param1:int, param2:int) : DataProvider
        {
            var _loc_6:* = undefined;
            var _loc_3:* = this.getCurrentPassRewards(param2);
            var _loc_4:* = new DataProvider();
            var _loc_5:int = 0;
            while (_loc_5 < param1)
            {
                
                if (_loc_3 && _loc_5 < _loc_3.length)
                {
                    _loc_6 = _loc_3[_loc_5];
                }
                else
                {
                    _loc_6 = new Object();
                }
                _loc_4.addItem(_loc_6);
                _loc_5++;
            }
            return _loc_4;
        }// end function

        public function getPassRewardsByLevelDataProvider(param1:int, param2:int, param3:int) : DataProvider
        {
            var _loc_7:* = undefined;
            var _loc_4:* = TowerCopyConfig.instance.getPassRewardsByID(param3, param1);
            var _loc_5:* = new DataProvider();
            var _loc_6:int = 0;
            while (_loc_6 < param2)
            {
                
                if (_loc_4 && _loc_6 < _loc_4.length)
                {
                    _loc_7 = _loc_4[_loc_6];
                }
                else
                {
                    _loc_7 = new Object();
                }
                _loc_5.addItem(_loc_7);
                _loc_6++;
            }
            return _loc_5;
        }// end function

        public function getHasMoney(param1:int) : Boolean
        {
            var _loc_2:Boolean = false;
            var _loc_3:* = undefined;
            for each (_loc_3 in this.towerInfoDic[param1.toString()].money)
            {
                
                _loc_2 = true;
                break;
            }
            return _loc_2;
        }// end function

        public function delAllMoney(param1:int) : void
        {
            var _loc_2:String = null;
            for (_loc_2 in this.towerInfoDic[param1.toString()].money)
            {
                
                delete this.towerInfoDic[param1.toString()].money[_loc_2];
            }
            return;
        }// end function

        public function getIsFirstKill(param1:int, param2:int) : Boolean
        {
            return param2 > this.towerInfoDic[param1.toString()].maxPassLevel;
        }// end function

        public function getIsMaxLv(param1:int, param2:int) : Boolean
        {
            return TowerCopyConfig.instance.getInfoByID(param1, (param2 + 1)) == null;
        }// end function

    }
}
